package com.vision.mapper;

import com.vision.pojo.entity.Comment;
import com.vision.pojo.vo.CommentVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {
    /**
     * 添加评论
     * @param userId 用户id
     * @param videoId 视频id
     * @param content 评论内容
     * @param parentCommentId 父评论id
     * @param replyUserId 回复用户id
     */
    void insert(Integer userId, Integer videoId, String content, Integer parentCommentId, Integer replyUserId);

    /**
     * 删除视频评论
     * @param videoId 视频id
     */
    @Delete("delete from vs_comment where video_id = #{videoId}")
    void deleteByVideoId(Integer videoId);

    /**
     * 获取父评论
     * @param videoId 视频id
     * @return java.util.List<com.vision.pojo.vo.CommentVO>
     */
    List<CommentVO> selectParentComment(Integer videoId,Integer userId);

    /**
     * 获取子评论
     * @param videoId 视频id
     * @param parentId 父评论id
     * @return java.util.List<com.vision.pojo.vo.CommentVO>
     */
    List<CommentVO> selectSonComment(Integer videoId, Integer parentId, Integer userId);

    /**
     * 获取单条评论
     * @param userId 用户id
     * @param videoId 视频id
     * @param parentCommentId 父评论id
     * @param replyUserId 回复用户id
     * @return com.vision.pojo.vo.CommentVO
     */
    CommentVO selectCommentSingle(Integer userId, Integer videoId, Integer parentCommentId, Integer replyUserId);

    /**
     * 获取视频评论
     * @param videoId 视频id
     * @return java.util.List<com.vision.pojo.entity.Comment>
     */
    @Select("select id from vs_comment where video_id = #{videoId}")
    List<Integer> selectCommentIdsByVideoId(Integer videoId);
}
